import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/view/layout/index.vue'

import produceManageRouter from './modules/produceManage'
import factorRouter from './modules/factor'
import reportRouter from './modules/report'
import serviceRouter from './modules/service'
import warningRouter from './modules/warning'
import setRouter from './modules/set'

export const menus = [
  {
    path: 'index',
    name: 'Index',
    hidden: false,
    meta: { title: '生产看板', icon: 'micon1.png', target: '_blank' },
    redirect: '/landDetail',
    // component: () => import('@/view/dashboard/index.vue'),
  },
  ...factorRouter,
  ...produceManageRouter,
  ...reportRouter,
  ...warningRouter,
  ...serviceRouter,
  ...setRouter
]

export const routes = [
  {
    path: '/',
    name: 'layout',
    meta: { title: 'layout', icon: 'odometer' },
    hidden: false,
    redirect: '/factor/land/index',
    component: Layout,
    children: menus
  },
  {
    path: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    meta: { title: '生产看板' },
    component: () => import('@/view/dashboard/index.vue')
  },
  {
    path: '/landDetail',
    name: 'landDetail',
    hidden: true,
    meta: { title: '生产看板' },
    component: () => import('@/view/dashboard/landDetail.vue')
  },
  {
    path: '/login',
    name: 'Login',
    hidden: true,
    component: () => import('@/view/login/index.vue'),
    meta: { title: '登录' }
  },
  {
    path: '/agreement',
    name: 'agreement',
    hidden: true,
    component: () => import('@/view/other/agreement.vue'),
    meta: { title: '用户协议' }
  },
  {
    path: '/404',
    name: '404',
    hidden: true,
    component: () => import('@/view/error/index.vue'),
    meta: { title: '404' }
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
